*******************************************************************************************************************************
*******************************************************************************************************************************
* Documentation for Reproduction of
* Oliver and Lee 2004 TESS Survey Experiment
* TESS Race Discrimination Meta-Analysis
* Stata version 15
* Data available here: http://www.tessexperiments.org/data/oliver159.html
*******************************************************************************************************************************
*******************************************************************************************************************************

* use "TESS_Oliver_Client.dta", clear
set more off

*******************************************************************************************************************************
*** Racial groups
*******************************************************************************************************************************

tab ppeth
gen whiteR = ppeth
recode whiteR (2/4=0)
tab ppeth whiteR
gen blackR = ppeth
recode blackR (1 3 4=0) (2=1)
tab ppeth blackR
gen hispnR = ppeth
recode hispnR (1/3=0) (4=1)
tab ppeth hispnR

*******************************************************************************************************************************
*** Treatments
*******************************************************************************************************************************

tab group
gen whitefemaleT = 0
gen blackfemaleT = 0
gen whitemaleT = 0
gen blackmaleT = 0
replace whitefemaleT = 1 if group==1 | group==2
replace blackfemaleT = 1 if group==3 | group==4
replace whitemaleT = 1 if group==1 | group==3
replace blackmaleT = 1 if group==2 | group==4
tab group whitefemaleT
tab group blackfemaleT
tab group whitemaleT
tab group blackmaleT

*******************************************************************************************************************************
*** Outcome variables
*******************************************************************************************************************************

egen overweightFEMALE_std = std(overwt1)
egen overweightMALE_std = std(overwt2)
egen obeseFEMALE_std = std(obese1)
egen obeseMALE_std = std(obese2)

alpha overweightFEMALE_std obeseFEMALE_std, item std min(1) gen(omnibusFEMALE)
alpha overweightMALE_std obeseMALE_std, item std min(1) gen(omnibusMALE)

sum omnibusFEMALE if whiteR==1
di r(sd)
gen ovFEMALE_white_std = omnibusFEMALE/r(sd) if whiteR==1

sum omnibusFEMALE if blackR==1
di r(sd)
gen ovFEMALE_black_std = omnibusFEMALE/r(sd) if blackR==1

sum omnibusFEMALE if hispnR==1
di r(sd)
gen ovFEMALE_hispn_std = omnibusFEMALE/r(sd) if hispnR==1

sum omnibusMALE if whiteR==1
di r(sd)
gen ovMALE_white_std = omnibusMALE/r(sd) if whiteR==1

sum omnibusMALE if blackR==1
di r(sd)
gen ovMALE_black_std = omnibusMALE/r(sd) if blackR==1

sum omnibusMALE if hispnR==1
di r(sd)
gen ovMALE_hispn_std = omnibusMALE/r(sd) if hispnR==1

*******************************************************************************************************************************
*** Racial manipulation check
*******************************************************************************************************************************

// No racial manipulation check

*******************************************************************************************************************************
*** Main regressions [Unweighted]
*******************************************************************************************************************************

reg ovFEMALE_white_std blackfemaleT if whiteR==1
reg ovFEMALE_black_std blackfemaleT if blackR==1
reg ovFEMALE_hispn_std blackfemaleT if hispnR==1

reg ovMALE_white_std blackmaleT if whiteR==1
reg ovMALE_black_std blackmaleT if blackR==1
reg ovMALE_hispn_std blackmaleT if hispnR==1

*******************************************************************************************************************************
*** Combining results [Unweighted]
*******************************************************************************************************************************

correlate ovFEMALE_white_std ovMALE_white_std if whiteR==1
correlate ovFEMALE_black_std ovMALE_black_std if blackR==1
correlate ovFEMALE_hispn_std ovMALE_hispn_std if hispnR==1
